package cn.group7.padserver.interceptor;

import cn.group7.padserver.interceptor.Interceptor.JwtInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @author 谷汉斌
 * @description 拦截器配置类
 * @createTime 2024/7/22 下午3:16
 */
//@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport {
    /**
     * 配置拦截器
     */
    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        // 注册jwt拦截器
        registry.addInterceptor(new JwtInterceptor())
                .addPathPatterns("")
                // 排除登录和注册接口
                .excludePathPatterns("/**");
        super.addInterceptors(registry);
    }
    /**
     * 引入jwt拦截器规则类
     * @return jwt拦截器
     */
    @Bean
    public JwtInterceptor jwtInterceptor() {
        return new JwtInterceptor();
    }
}
